package study.javabasic.Thread;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

public class MyCallable implements Callable<String> {
    @Override
    public String call() throws Exception {
        System.out.println("in hand please waiting");
        Thread.sleep(1000);
        System.out.println("finish");
        return "result";
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask=new FutureTask<String>(new MyCallable());
        new Thread(futureTask).start();
        if(!futureTask.isDone()){
            System.out.println("waiting please");
        }
        System.out.println(futureTask.get());
    }
}
